package cn.ava.ymcc.web.controller;

import cn.ava.ymcc.result.JSONResult;
import cn.ava.ymcc.service.ITokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/token")
public class TokenController {

    @Autowired
    private ITokenService tokenService;

    @GetMapping("/createToken/{courseId}")
    public JSONResult createToken(@PathVariable @NotNull(message = "参数非法!") String courseId) {
        String token = tokenService.createToken(courseId);
       return JSONResult.success(token);
    }

}
